A user interface displays elements that can be moved in the user interface. For example, a user may scroll an element in different directions in the user interface. To process the movement, a computing device may include a user interface thread and a rendering thread. The user interface thread may receive the input and then direct the rendering thread to move the element linearly in a direction. The rendering thread can then move the element in the user interface.
Some types of elements may require the rendering thread to query the user interface thread to determine whether actions should be performed during the movement of the element. For example, a sticky header causes an element to “stick” or stop movement at a sticky position on the user interface even though the input is still moving. A sticky header may stop moving at the sticky position for a certain amount of time while the movement from the input is still ongoing, such as from a flick movement that moves the element with inertia in a direction. To determine whether the element should be stopped while the input is still moving, the rendering thread may continuously send queries to the user interface thread asking whether or not the element should be in the sticky position. When the element reaches the sticky position, the user interface thread responds to the rendering thread with a message directing the rendering thread to stop movement of the element. The process to determine when to stop movement of the element causes a lot of querying back and forth between the rendering thread and the user interface thread. Further, because of the time it takes the rendering thread to query the user interface thread and then receive a response from the user interface thread, the rendering of the element may be behind the time of the user interface thread. This may result in an inaccurate rendering of the element, which may cause a choppy display of the movement of the element. For example, the element may go past the sticky position because the rendering thread has not yet received a response from the user input thread. Then, when the rendering thread receives the response directing it to stop movement of the element at the sticky position, the rendering thread has to move the element back to the sticky position, which results in a choppy display of the element. Further, the rendering thread may be late in unsticking the element when it is time to move the element from the sticky position because the rendering thread has to similarly query the user interface thread to determine when to unstick the element and start movement of the element again.